package com.asion.qkan.ui.fragment;


import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.asion.qkan.R;
import com.asion.qkan.adapters.RemenAdapter;
import com.asion.qkan.entry.ReMenBean;
import com.asion.qkan.ui.contract.SheQuReMenContract;
import com.asion.qkan.ui.model.SheQuReMenModel;
import com.asion.qkan.ui.presenter.SheQuReMenPresenter;

import butterknife.BindView;

public class SheQuReMenFragment extends BaseFragment<SheQuReMenPresenter,SheQuReMenModel> implements SheQuReMenContract.View {
    @BindView(R.id.Remen_recycler)
    RecyclerView recyclerView;
    private RemenAdapter adapter;

    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_she_qu_re_men;
    }

    @Override
    public void initPresenter() {
        mPresenter.setVM(this,mModel);
        mPresenter.setSheQuReMenDatas(2);
    }

    @Override
    protected void initView() {
        adapter = new RemenAdapter(getContext());
        recyclerView.setAdapter(adapter);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(linearLayoutManager);
    }

    @Override
    public void showDataSuccess(ReMenBean.DataBean bean) {
        adapter.addAll(bean.getFeeds());

    }

    @Override
    public void showDataError(Throwable throwable) {
        Toast.makeText(getContext(),"请求失败",Toast.LENGTH_SHORT).show();
    }
}
